package com.by.auto.token;

import com.auth0.jwt.JWT;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@AutoConfiguration//声明为自动配置类
@ConditionalOnClass(JWT.class)
@EnableConfigurationProperties({TokenProperties.class})//属性绑定
@ConditionalOnProperty(prefix = "token", value = "enabled", matchIfMissing = true)
public class TokenAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public TokenTemplate tokenTemplate(){
        return new TokenTemplate();
    }
}
